﻿<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true"
    CodeFile="Statistics.aspx.cs" Inherits="Admin_Statistics" Title="Admin Page - Information Literacy Education" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <h1>
                Statistics Page
            </h1>
            <br />
            <div style="margin-left: 20px;">
                <asp:Button ID="btnOpenLoginStats" runat="server" Text="Login Stats." OnClick="btnOpenLoginStats_Click" />
                &nbsp;&nbsp;&nbsp;
                <asp:Button ID="btnOpenLearnObjStats" runat="server" Text="Learning Object Stats."
                    OnClick="btnOpenLearnObjStats_Click" />
                <%--&nbsp;&nbsp;&nbsp;
                <asp:Button ID="btnOpenQuizStats" runat="server" Text="Quiz Stats." OnClick="btnOpenQuizStats_Click" />--%>
                <br />
                <br />
                <asp:Panel ID="PanelLoginStats" runat="server" Visible="false">
                    <h2>
                        Login Statistics
                    </h2>
                    <div style="margin-left: 20px;">
                        <table>
                            <tr>
                                <td class="tableLeftHeader">
                                    Network ID :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtLoginNetworkID" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Account Type :
                                </td>
                                <td class="tableItem">
                                    <asp:DropDownList ID="ddlistLoginAccountType" runat="server">
                                        <asp:ListItem Selected="True" Value="All">All</asp:ListItem>
                                        <asp:ListItem Value="Student">Students</asp:ListItem>
                                        <asp:ListItem Value="Instructor">Instructors</asp:ListItem>
                                        <asp:ListItem Value="Admin">Admins</asp:ListItem>
                                        <asp:ListItem Value="NonInstitute">Non-Institute Users</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Start Date :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtLoginStartDate" runat="server" Width="70"></asp:TextBox>
                                    <asp:ImageButton ID="imgbtnLoginStartDate" runat="server" ImageUrl="~/Images/calendarIcon.png"
                                        CausesValidation="False" />
                                    <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="txtLoginStartDate"
                                        Mask="99/99/9999" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus"
                                        OnInvalidCssClass="MaskedEditError" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"
                                        ErrorTooltipEnabled="True" />
                                    <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlExtender="MaskedEditExtender1"
                                        ControlToValidate="txtLoginStartDate" EmptyValueMessage="Start Date is required"
                                        InvalidValueMessage="Start Date is invalid" Display="Dynamic" TooltipMessage="Input a Start date"
                                        EmptyValueBlurredText="*" InvalidValueBlurredMessage="*" />
                                    <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtLoginStartDate"
                                        PopupButtonID="imgbtnLoginStartDate" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    End Date :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtLoginEndDate" runat="server" Width="70"></asp:TextBox>
                                    <asp:ImageButton ID="imgbtnLoginEndDate" runat="server" ImageUrl="~/Images/calendarIcon.png"
                                        CausesValidation="False" />
                                    <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender7" runat="server" TargetControlID="txtLoginEndDate"
                                        Mask="99/99/9999" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus"
                                        OnInvalidCssClass="MaskedEditError" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"
                                        ErrorTooltipEnabled="True" />
                                    <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator7" runat="server" ControlExtender="MaskedEditExtender7"
                                        ControlToValidate="txtLoginEndDate" EmptyValueMessage="End Date is required"
                                        InvalidValueMessage="End Date is invalid" Display="Dynamic" TooltipMessage="Input a End date"
                                        EmptyValueBlurredText="*" InvalidValueBlurredMessage="*" />
                                    <ajaxToolkit:CalendarExtender ID="CalendarExtender4" runat="server" TargetControlID="txtLoginEndDate"
                                        PopupButtonID="imgbtnLoginEndDate" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td class="tableItem">
                                    <br />
                                    <asp:Button ID="btnLoginSearch" runat="server" Text="Search" OnClick="btnLoginSearch_Click" />
                                </td>
                            </tr>
                        </table>
                        <asp:Panel ID="PanelLoginResults" runat="server" Visible="false">
                            <br />
                            <br />
                            <h3>
                                Results
                            </h3>
                            <div style="margin-left: 20px;">
                                <asp:ObjectDataSource ID="ObjectDataSourceLoginResults" runat="server" OldValuesParameterFormatString="original_{0}"
                                    SelectMethod="GetStatsLoginsForStatsPage" TypeName="StatisticsBLL">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="txtLoginNetworkID" Name="NetworkID" PropertyName="Text"
                                            Type="String" />
                                        <asp:ControlParameter ControlID="ddlistLoginAccountType" Name="AccountType" PropertyName="SelectedValue"
                                            Type="String" />
                                        <asp:ControlParameter ControlID="txtLoginStartDate" Name="StartDateTime" PropertyName="Text"
                                            Type="String" />
                                        <asp:ControlParameter ControlID="txtLoginEndDate" Name="EndDateTime" PropertyName="Text"
                                            Type="String" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                                <asp:GridView ID="GridViewLoginResults" runat="server" CellPadding="4" ForeColor="#333333"
                                    GridLines="None" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="StatsLoginID"
                                    DataSourceID="ObjectDataSourceLoginResults" EmptyDataText="No Logins Found" AllowPaging="True"
                                    PageSize="200">
                                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                    <Columns>
                                        <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
                                        <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
                                        <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
                                        <asp:BoundField DataField="LoginDateTime" HeaderText="Login Time" SortExpression="LoginDateTime" />
                                        <asp:BoundField DataField="LogoutDateTime" HeaderText="Logout Time" SortExpression="LogoutDateTime" />
                                        <asp:BoundField DataField="Browser" HeaderText="Browser" SortExpression="Browser" />
                                    </Columns>
                                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                    <EditRowStyle BackColor="#999999" />
                                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                </asp:GridView>
                                <br />
                                <asp:Button ID="btnLoginExportToExcel" runat="server" Text="Export to Excel" OnClick="btnLoginExportToExcel_Click" />
                            </div>
                        </asp:Panel>
                    </div>
                </asp:Panel>
                <asp:Panel ID="PanelQuizStats" runat="server" Visible="false">
                    <h2>
                        Quiz Statistics
                    </h2>
                    <br />
                    <div style="margin-left: 20px;">
                        <h3>
                            Overall Average score by quiz:
                        </h3>
                        <div style="margin-left: 20px;">
                            <asp:Repeater ID="RepeaterQuizStats" runat="server">
                                <HeaderTemplate>
                                    <ol>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <li>Standard
                                        <asp:Label ID="lblQuizStandard" runat="server" />
                                    </li>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </ol>
                                </FooterTemplate>
                            </asp:Repeater>
                        </div>
                    </div>
                </asp:Panel>
                <asp:Panel ID="PanelLearnObjStats" runat="server" Visible="false">
                    <h4>
                        Courses
                    </h4>
                    <div style="margin-left: 20px;">
                        <asp:ObjectDataSource ID="ObjectDataSourceCourseList" runat="server" DeleteMethod="DeleteCourse"
                            InsertMethod="InsertCourseSection" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="GetCourses" TypeName="ClassBLL" UpdateMethod="UpdateCourse">
                            <DeleteParameters>
                                <asp:Parameter Name="courseID" Type="Int32" />
                            </DeleteParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="Title" Type="String" />
                                <asp:Parameter Name="Subtitle" Type="String" />
                                <asp:Parameter Name="Introduction" Type="String" />
                                <asp:Parameter Name="IsEnabled" Type="Boolean" />
                                <asp:Parameter Name="CourseID" Type="Int32" />
                            </UpdateParameters>
                            <InsertParameters>
                                <asp:Parameter Name="courseID" Type="Int32" />
                                <asp:Parameter Name="sectionNumber" Type="Int32" />
                                <asp:Parameter Name="useSectionInfo" Type="Boolean" />
                                <asp:Parameter Name="subtitle" Type="String" />
                                <asp:Parameter Name="introduction" Type="String" />
                                <asp:Parameter Name="classTime" Type="String" />
                                <asp:Parameter Name="isEnabled" Type="Boolean" />
                            </InsertParameters>
                        </asp:ObjectDataSource>
                        <asp:GridView ID="GridViewLearnObjStatsCourseList" runat="server" AllowPaging="True"
                            AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="CourseID"
                            DataSourceID="ObjectDataSourceCourseList" ForeColor="#333333" GridLines="None"
                            Width="780" OnSelectedIndexChanged="GridViewLearnObjStatsCourseList_SelectedIndexChanged">
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <Columns>
                                <asp:CommandField ShowSelectButton="True" />
                                <asp:BoundField DataField="CourseID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                    SortExpression="CourseID" />
                                <asp:BoundField DataField="Title" HeaderText="Class Title" SortExpression="Title" />
                                <asp:BoundField DataField="Subtitle" HeaderText="Class Subtitle" SortExpression="Subtitle" />
                                <asp:CheckBoxField DataField="IsEnabled" HeaderText="Enabled?" SortExpression="IsEnabled" />
                            </Columns>
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#999999" />
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        </asp:GridView>
                    </div>
                    <br />
                    <asp:Panel ID="PanelLearnObjStatsSections" runat="server" Visible="false">
                        <h4>
                            Sections
                        </h4>
                        <div style="margin-left: 20px;">
                            <asp:DropDownList ID="ddlistSections" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlistSections_SelectedIndexChanged">
                            </asp:DropDownList>
                        </div>
                        <br />
                        <h4>
                            Standard
                        </h4>
                        <div style="margin-left: 20px;">
                            <asp:RadioButtonList ID="RadioButtonListStandardID" runat="server" RepeatDirection="Horizontal"
                                AutoPostBack="True" OnSelectedIndexChanged="RadioButtonListStandardID_SelectedIndexChanged">
                                <asp:ListItem Value="1" Selected="True">Getting Started</asp:ListItem>
                                <asp:ListItem Value="2">Finding Sources</asp:ListItem>
                                <asp:ListItem Value="3">Evaluating Sources</asp:ListItem>
                                <asp:ListItem Value="4">Writing with Sources</asp:ListItem>
                            </asp:RadioButtonList>
                        </div>
                    </asp:Panel>
                    <br />
                    <asp:Panel ID="PanelLearnObjStatsLearnObjs" runat="server" Visible="false">
                        <h4>
                            Learning Objects
                        </h4>
                        <div style="margin-left: 20px;">
                            <ul>
                                <asp:Repeater ID="RepeaterLearningObj" runat="server" OnItemDataBound="RepeaterLearningObj_ItemDataBound">
                                    <ItemTemplate>
                                        <li>
                                            <asp:LinkButton ID="lnkbtnSelectLearningObj" runat="server" OnCommand="lnkbtnSelectLearningObj_Click" />
                                            &nbsp;&nbsp; </li>
                                    </ItemTemplate>
                                </asp:Repeater>
                                <asp:Label runat="server" ID="lblNoLearnObj" Visible="false" Text="<p style='font-weight: bold;'>No Learning Objects</p>"></asp:Label>
                            </ul>
                        </div>
                    </asp:Panel>
                    <asp:Panel ID="PanelLearnObjStatsLearnObjsList" runat="server" Visible="false">
                        <asp:DropDownList ID="ddlistSelectedLearnObjID" runat="server" Visible="false">
                        </asp:DropDownList>
                        <h4>
                            Users viewed
                            <asp:Label ID="lblLearnObjStatsSelectedLearnObj" runat="server"></asp:Label>
                        </h4>
                        <div style="margin-left: 20px;">
                            <asp:ObjectDataSource ID="ObjectDataSourceStatsLearnObjs" runat="server" OldValuesParameterFormatString="original_{0}"
                                SelectMethod="GetLearnObjStatsUsers" TypeName="StatisticsBLL">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="GridViewLearnObjStatsCourseList" Name="CourseID"
                                        PropertyName="SelectedValue" Type="Int32" />
                                    <asp:ControlParameter ControlID="ddlistSections" Name="SectionNumber" PropertyName="SelectedValue"
                                        Type="Int32" />
                                    <asp:ControlParameter ControlID="RadioButtonListStandardID" Name="StandardID" PropertyName="SelectedValue"
                                        Type="Int32" />
                                    <asp:ControlParameter ControlID="ddlistSelectedLearnObjID" DefaultValue="0" Name="LearnObjID"
                                        PropertyName="SelectedValue" Type="Int32" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                            <asp:GridView ID="GridViewStatsLearnObjs" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                                CellPadding="4" DataSourceID="ObjectDataSourceStatsLearnObjs" ForeColor="#333333"
                                GridLines="None" EmptyDataText="<b>No users in this section have viewed the Learning Object yet.</b>">
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <Columns>
                                    <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
                                    <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
                                    <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
                                    <%--<asp:BoundField DataField="ViewDateTime" HeaderText="ViewDateTime" SortExpression="ViewDateTime" />--%>
                                    <asp:BoundField DataField="ClickedDateTime" HeaderText="Viewed Time" SortExpression="ClickedDateTime" />
                                </Columns>
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <EditRowStyle BackColor="#999999" />
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            </asp:GridView>
                            <br />
                            <asp:Button ID="btnLearnObjStatsExportToExcel" runat="server" Text="Export to Excel"
                                OnClick="btnLearnObjStatsExportToExcel_Click" />
                        </div>
                    </asp:Panel>
                </asp:Panel>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger ControlID="btnLoginExportToExcel" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
